<?php 
namespace Qwadmin\Controller;

class BranController extends ComController
{

	public function index()
	{

		// // $db = M("stock");
  //       // $where = "a_id=".$uid;
        $gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		// dump($gid);
		// exit;
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		// $title = substr($glist[0]['title'], 0,2);
		// dump($glist);
		// exit;
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		// dump($glist);
		// exit;
		$ggid = $glist[0]['post'];
        $count = M('member')->join('oa_auth_group_access as t1 on t1.uid = oa_member.uid')->join('oa_auth_group as t2 on t2.id = t1.group_id')->where(['oa_member.upost'=>$ggid])->count();
       	// dump($count);
        // exit;
        $pagecount = 15;
        $page = new \Think\Page($count , $pagecount);
        // $row[] = '';
        $page->parameter = $row; //此处的row是数组，为了传递查询条件
        $page->setConfig('first');
        $page->setConfig('prev','上一页');
        $page->setConfig('next','下一页');
        $page->setConfig('last','尾页');
        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
        $show = $page->show();
        $list = M('member')->join('oa_auth_group_access as t1 on t1.uid = oa_member.uid')->join('oa_auth_group as t2 on t2.id = t1.group_id')->where(['oa_member.upost'=>$ggid])->limit($page->firstRow.','.$page->listRows)->select();
        $this->assign('list',$list);
        $this->assign('page',$show);


			
		// $list = M('member')->join('oa_auth_group_access as t1 on t1.uid = oa_member.uid')->join('oa_auth_group as t2 on t2.id = t1.group_id')->select();

		
		// dump($list);
		// exit;
        $b_list = M('auth_group')->select();
        $this->assign('blist',$b_list);
        // $this->assign('list',$list);
		$this->display();
	}







	public function bsou()
	{	
		
		$title = $_POST['title'];
		if (!empty($title)) {
			$list = M('member')->join('oa_auth_group_access as t1 on t1.uid = oa_member.uid')->join('oa_auth_group as t2 on t2.id = t1.group_id')->where(['t2.title'=>$title])->select();
		// 	dump($list);
		// exit;
			$b_list = M('auth_group')->select();
	        $this->assign('blist',$b_list);
	        $this->assign('list',$list);
			$this->display();
			
			
		}

	}





	//异步根据Id删除管理员
    public function ajaxDel() {
        $uid = I('get.uid');
        $result = D('member')->delete($uid);
        $this->ajaxReturn($result);
    }



















}